Repository navigation
Conversation
Fixes the flaws listed in #543: - Run the auto-rollback with the values of the request context but without its cancellation, so it no longer fails on a dead context. - Replace the custom cancel timer with time.AfterFunc. Confirm, Cancel and the timer are arbitrated under the TransactionManager lock, which removes the double-close panic and the data race. - Validate the transaction id before Confirm, Cancel and the auto rollback act, so a wrong id has no side effects and a late timer cannot unregister a newer transaction. - Take the set-path lock (dmutex) in the auto-rollback, keeping the lock order dmutex -> tmMutex, and take tmMutex in the guard cleanup. - Keep a transaction registered when its rollback fails so Cancel can retry. - Arm the timer for no-op transactions; on timeout they only unregister. - Do not use the transaction guard in dry-run and do not apply or write back a replace intent in dry-run. - Drop dmutex from Confirm, which never touches the device, and reject Confirm for a transaction that is not committed yet. - Remove the single-iteration outerloop, map ErrTransactionOngoing to codes.Aborted and reject non-positive transaction timeouts. Signed-off-by: Markus Vahlenkamp <markus.vahlenkamp@nokia.com>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #543
What changed
TransactionCancelTimeris replaced bytime.AfterFunc. Confirm, Cancel and the timer are arbitrated under theTransactionManagerlock, which removes theclose of closed channelpanic and the data race. The auto-rollback checks under the lock that its transaction is still the registered one.dmutex(orderdmutex->tmMutex) via the newWithAutoRollbackLockoption, so it can't race Sync Revert andTransactionSetstays fail-fast. The guard cleanup now takestmMutex.dmutexsince it never touches the device, and rejects a transaction that is not committed yet. Cancel keepsdmutexbecause it rolls back on the device.outerloopremoved,ErrTransactionOngoingmaps tocodes.Aborted, and a non-positivetimeoutis rejected withInvalidArgument.Differences from the suggestions in the issue
dmutexand a registered transaction.dmutex; Cancel needs it.Not addressed
oldRunningis recorded after the replace is applied).IntentModify,writeBackSyncTree) still only unregister the transaction.dmutexandtmMutex.Behaviour changes for clients
Abortedinstead ofUnknown.timeout <= 0is rejected.Testing
go test -race ./pkg/datastore/... ./pkg/server/...passes. New regression tests cover each scenario from the issue (pkg/datastore/types/transaction_manager_test.go,pkg/datastore/transaction_lock_test.go).